package hbsi.edu.Test;

import hbsi.edu.dao.UsersDao;
import hbsi.edu.domain.Users;
import org.junit.Test;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
import java.util.List;

/**
 * @author 程奕红
 * @version 1.0
 */
public class TestGetAllUsers {
    public static void main(String[] args) throws SQLException {
        UsersDao dap=new UsersDao();
        List<Users> List=dap.getAllUsers();
            for(Users u :List){
                System.out.println(u);
            }
        }
        @Test
        public void testSelect() throws SQLException {
        UsersDao dao=new UsersDao();
        Users user=dao.getUserById(2);
            System.out.println(user);
        }
        @Test
        public void testInsert(){
        UsersDao dao=new UsersDao();
        Users user =new Users();
        user.setName("小恒");
        user.setPassword("123456");
        user.setEmail("3503222973");
        user.setBirthday(new Date());
        int n=dao.deleteUser(4);

        if(n>0){
            System.out.println("插入成功");
        }else{
            System.out.println("插入失败");
        }

        }
        @Test
        public void testDelete(){
        UsersDao dao=new UsersDao();
        int n=dao.deleteUser(4);
        if(n>0){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
        }
        @Test
    public void testAdd() throws SQLException {
        UsersDao dao=new UsersDao();
        Users user=dao.getUserById(1);

            System.out.println("user");
            user.setPassword("AAAAA");
            dao.addUser(user);

        }
        @Test
        public void testScrollResultSet() throws SQLException {
            UsersDao dao=new UsersDao();
            dao.testScrollResultSet();
        }
    }

